package cn.play.cardgame.widget;

import butterknife.ButterKnife;
import butterknife.InjectView;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import cn.play.cardgame.R;

public class CountPanel extends FrameLayout {
	@InjectView(R.id.heixin_count)
	TextView mTvHeixinCount;
	@InjectView(R.id.hongxin_count)
	TextView mTvHongxinCount;
	@InjectView(R.id.caohua_count)
	TextView mTvCaohuaCount;
	@InjectView(R.id.fangkuai_count)
	TextView mTvFangkuaiCount;
	@InjectView(R.id.king_count)
	TextView mTvKingCount;
	private Context mContext;
	private int heixinCount = 0;
	private int hongxinCount = 0;
	private int caohuaCount = 0;
	private int fangkuaiCount = 0;
	private int kingCount = 0;

	public CountPanel(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		mContext = context;
		initViews();
	}

	public CountPanel(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public CountPanel(Context context) {
		this(context, null);
	}

	private void initViews() {
		FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
				FrameLayout.LayoutParams.MATCH_PARENT,
				FrameLayout.LayoutParams.MATCH_PARENT);

		View view = View.inflate(mContext, R.layout.count_panel, null);
		ButterKnife.inject(this, view);
		this.addView(view, params);
	}

	public void addHeixinCount() {
		heixinCount++;
		mTvHeixinCount.setText(String.valueOf(heixinCount));
	}

	public void addHongxinCount() {
		hongxinCount++;
		mTvHongxinCount.setText(String.valueOf(hongxinCount));
	}

	public void addCaohuaCount() {
		caohuaCount++;
		mTvCaohuaCount.setText(String.valueOf(caohuaCount));
	}

	public void addFangkuaiCount() {
		fangkuaiCount++;
		mTvFangkuaiCount.setText(String.valueOf(fangkuaiCount));
	}

	public void addKingCount() {
		kingCount++;
		mTvKingCount.setText(String.valueOf(kingCount));
	}
	
	
	public void setHeixinCount(int count) {
		heixinCount = count;
		mTvHeixinCount.setText(String.valueOf(count));
	}

	public void setHongxinCount(int count) {
		hongxinCount = count;
		mTvHongxinCount.setText(String.valueOf(count));
	}

	public void setCaohuaCount(int count) {
		caohuaCount = count;
		mTvCaohuaCount.setText(String.valueOf(count));
	}

	public void setFangkuaiCount(int count) {
		fangkuaiCount = count;
		mTvFangkuaiCount.setText(String.valueOf(count));
	}

	public void setKingCount(int count) {
		kingCount = count;
		mTvKingCount.setText(String.valueOf(count));
	}

	public void reset() {
		heixinCount = 0;
		hongxinCount = 0;
		caohuaCount = 0;
		fangkuaiCount = 0;
		kingCount = 0;
		mTvHeixinCount.setText(String.valueOf(heixinCount));
		mTvHongxinCount.setText(String.valueOf(hongxinCount));
		mTvCaohuaCount.setText(String.valueOf(caohuaCount));
		mTvFangkuaiCount.setText(String.valueOf(fangkuaiCount));
		mTvKingCount.setText(String.valueOf(kingCount));
	}

}
